﻿using System.Linq;
using System.Web.Mvc;
using Lbb.URating.Controllers;
using Lbb.URating.Models;

namespace Lbb.URating.Areas.admin.Controllers
{
    /// <summary>
    /// 用户评分控制器
    /// </summary>
    /// <author>Chiron</author>
    public class U_RatingController : URatingControllerBase
    {
        #region Fields
        private const string _preKey = "U_Rating_";
        private readonly static string[] _listKeys = URatingControllerBase.listKeys.Union(new[] { 
            "categoryIds", "clickIds" ,"objTypes","objIds","minRating","maxRating","ratingIds"
        }).ToArray();
        #endregion Fields

        #region Pages
        /// <summary>
        /// 列表页面
        /// </summary>
        public ActionResult Index(int? pageNumber, int? pageSize, string keyword, string orderby,
            string categoryIds, string clickIds, string objTypes, string objIds, string ratingIds, decimal? minRating, decimal? maxRating)
        {
            Response.Expires = 0;
            CacheArgs(_preKey, _listKeys);
            var model = new U_RatingDataList();
            model.FillData(U_RatingRepository.Find(model.Keyword, model.CategoryIds, model.ClickIds, model.ObjtypeIds, model.ObjtypeIds, model.RatingIds, model.MinRating, model.MaxRating));
            return View(IsRequestPartial ? "List" : "Index", model);
        }
        /// <summary>
        /// 返回到上次查看的列表页
        /// </summary>
        public ActionResult RedirectToIndex()
        {
            return RedirectToAction("Index", GetCacheArgs(_preKey, _listKeys));
        }
        #endregion Pages
    }
}
